/*
 *  Copyright 2010 Wesley Gooch, Ryan Nix, Cody Wenzel.
 *  Montana State University - Spring Semester 2010
 *  Computer Science 450 - Compilers
 *  Project: Micro-Pascal Compiler
 */
package msu.compiler.errorhandling;

/**
 * This is a singleton class.
 *
 * @author Wesley
 */
public class ErrorHandler {

    private static ErrorHandler errorHandler;
    private boolean errorsExist = false;

    public static synchronized ErrorHandler getErrorHandler() {
        if (errorHandler == null) {
            errorHandler = new ErrorHandler();
        }
        return errorHandler;
    }

    public static void logError(String errorMessage) {
        disableCodeGeneration();
        System.out.println(errorMessage);
    }

    public static boolean doErrorsExist() {
        return getErrorHandler().getErrorsExistFlag();
    }

    public static void disableCodeGeneration() {
        getErrorHandler().setErrorsExistFlag(true);
    }

    public boolean getErrorsExistFlag() {
        return errorsExist;
    }

    public void setErrorsExistFlag(boolean errorsExist) {
        this.errorsExist = errorsExist;
    }
}
